package com.ss.android.account.a;

import com.google.gson.JsonSyntaxException;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;

import java.io.IOException;

public final class a extends TypeAdapter<Long> {
    public final Long read(com.google.gson.stream.JsonReader arg2) throws IOException {
        return a.b(arg2);
    }

    public final void write(JsonWriter arg2, Long arg3) throws IOException {
        if (arg3 == null) {
            arg2.nullValue();
        } else {
            arg2.value(String.valueOf(arg3));
        }
    }

    private static Long b(com.google.gson.stream.JsonReader arg2) throws IOException {
        Long v0;
        if (arg2.peek() == JsonToken.NULL) {
            arg2.nextNull();
            v0 = null;
        } else {
            try {
                v0 = arg2.peek() == JsonToken.NUMBER ? Long.valueOf(arg2.nextLong()) : Long.valueOf(Long.parseLong(arg2.nextString().trim()));
            } catch (Exception v0_1) {
                throw new JsonSyntaxException(((Throwable) v0_1));
            }
        }

        return v0;
    }
}

